import {RouteRecordRaw} from "vue-router";
import ExampleView from "@/views/ExampleView.vue";
import AdminView from "@/views/AdminView.vue";
import NoAuthView from "@/views/NoAuthView.vue";
import UserLayout from "@/layouts/UserLayout.vue";
import UserLoginView from "@/views/user/UserLoginView.vue";
import UserRegisterView from "@/views/user/UserRegisterView.vue";
import AddQuestionView from "@/views/question/AddQuestionView.vue";
import ManageQuestionView from "@/views/question/ManageQuestionView.vue";
import QuestionsView from "@/views/question/QuestionsView.vue";
import QuestionsSubmitView from "@/views/question/QuestionsSubmitView.vue";
import ViewQuestionView from "@/views/question/ViewQuestionView.vue";
import accessEnum from "@/access/accessEnum";

export const routes: Array<RouteRecordRaw> = [

    {
        path: "/user",
        name: "用户登录",
        component: UserLayout,
        children: [
            {
                path: "/user/login",
                name: "用户登录",
                component: UserLoginView,
            },
            {
                path: "/user/register",
                name: "用户注册",
                component: UserRegisterView,
            },
        ],
        meta: {
            hideInMenu: true
        }
    },

    {
        path: "/",
        name: "样例",
        component: QuestionsView,
    },

    {
        path: "/questions",
        name: "题库",
        component: QuestionsView,
    },

    {
        path: "/questions_submit",
        name: "提交列表",
        component: QuestionsSubmitView,
    },

    {
        path: "/view/question/:id",
        name: "在线做题",
        component: ViewQuestionView,
        props: true,
        meta: {
            access: accessEnum.USER,
            hideInMenu: true,
        },
    },

    {
        path: "/add/question",
        name: "创建题目",
        component: AddQuestionView,
        meta: {
            access: accessEnum.USER
        }
    },

    {
        path: "/update/question",
        name: "更新题目",
        component: AddQuestionView,
        meta: {
            access: accessEnum.USER,
            hideInMenu: true
        }
    },

    {
        path: "/manage/question/",
        name: "管理题目",
        component: ManageQuestionView,
        meta: {
            access: accessEnum.ADMIN,
        },
    },

    {
        path: "/admin",
        name: "管理员题库",
        component: AdminView,
        meta: {
            access: accessEnum.ADMIN
        }
    },

    {
        path: "/noAuth",
        name: "无权限",
        component: NoAuthView,
        meta: {
            hideInMenu: true
        }
    },

    {
        path: "/about",
        name: "关于",
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () =>
            import(/* webpackChunkName: "about" */ "../views/AboutView.vue"),
    },

];

